{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "08d8c067",
   "metadata": {},
   "source": [
    "* 本学习记录人：莫金婵\n",
    "* 学习时间：2021-11-11\n",
    "* week06\n",
    "* [参考文档](https://www.python.org/doc/)\n",
    "* [博客](https://www.cnblogs.com/xuzhichao)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e813d8ff",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "\n",
    "## 1.认识[列表](https://docs.python.org/3/tutorial/introduction.html#lists)\n",
    "\n",
    "## 2.列表的取值\n",
    "\n",
    "## 3.列表的一般方法\n",
    "\n",
    "## 4.列表的高级方法\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f303df1",
   "metadata": {},
   "source": [
    "### 1.1.初始列表\n",
    "\n",
    "> 1. 列表的样式：[元素1,元素2,元素3.....]\n",
    "> 2. 列表的性质：\n",
    ">>列表是有顺序的（Sequence Types 序列类型的数据），第一个元素的位置/索引（index）是 0\n",
    ">>列表可以存放不同的类型数据， 但是 一般存放相同类型数据\n",
    ">>列表可以按照序列数据 进行 取值（index） & 切片（slices）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9dd31a07",
   "metadata": {},
   "outputs": [],
   "source": [
    "squares = [1,2,3,4,5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "23c545e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5bbefd34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 22, 55, 66, 77]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares + [22,55,66,77]#列表串联"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "dbacc3b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "username_database = \"alex;jack;jinchan;marry\"\n",
    "username_database_list = [\"alex\",\"jack\",\"jinchan\",\"marry\"]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "24635b94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jack'"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 目标取出每一个账号名称\n",
    "\n",
    "username_database[5:9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "4886befe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jack'"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "6c6e1dea",
   "metadata": {},
   "outputs": [],
   "source": [
    "#列表中可以包含不同的 types （int\\float\\str..也可是列表）数据 * 不常这样用\n",
    "different_types_list = [\"alex\",18,175.5,[\"广东省广州市广州南方学院\",510970]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "fed293bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'alex'"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "different_types_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "5f3eea69",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "different_types_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "6bc7e78a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "175.5"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "different_types_list[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "9d8d61ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['广东省广州市广州南方学院', 510970]"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "different_types_list[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "1b05c3d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "510970"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "different_types_list[3][1]# 在3里面取1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "6e73d520",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考： 取值是否需要知道列表的长度？如果列表只有5个元素，取值不能取5以上\n",
    "\n",
    "squares = [1, 4, 9, 16, 25]\n",
    "print(squares[0])\n",
    "#print(square[10]) #IndexError（索引错误）: list index out of range\n",
    "#一般 列表的取值 要先知道列表的长度 取值不要超过列表的范围\n",
    "len(squares)#取值 不应该大于 长度5 位置4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7ceb1b7",
   "metadata": {},
   "source": [
    "# 2.1切片 （slices）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "238716e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9, 16, 25]"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "9ae34a92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[9, 16]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 从左往右 正向取9和16：\n",
    "squares[2:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "018df10c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[9, 16]"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 负向取（从右往左）\n",
    "squares[2:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "7c72e499",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[9, 16, 25]"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 从右往左 9，16，25: 结论：取到末尾或首位都一律不屑最好\n",
    "squares[-3:]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "2fd8a4d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "squares[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "f0863c92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 9]"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取1，9？ 回顾切片步长stop\n",
    "squares[:3:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f12313d",
   "metadata": {},
   "source": [
    "# 2.2列表取值实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "338a54c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "vowels = ['a','e','i','o','u']# vowels 元音 [\"数字媒体\"]\n",
    "word = \"Milliways\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "dfc2ed15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "#请检查word中出现了那些vowels中的元素 并打印出来\n",
    "#知识点：\n",
    "#1.for循环和if条件判断   2.in判断是否在列表中 切片 （slices）\n",
    "for i in word:\n",
    "    if i in vowels:\n",
    "        print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e415bafc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "i\n"
     ]
    }
   ],
   "source": [
    "# 请检查 vowels中出现的word：\n",
    "for i in vowels:\n",
    "    if i in word:\n",
    "        print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3c1afb5a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你要查的文本: agcyufbsgyucyuyetwuib\n",
      "0 a\n",
      "4 u\n",
      "10 u\n",
      "13 u\n",
      "15 e\n",
      "18 u\n",
      "19 i\n"
     ]
    }
   ],
   "source": [
    "#枚举：确定其出现的位置\n",
    "user_word = input(\"请输入你要查的文本: \")\n",
    "for i,v in enumerate(user_word):\n",
    "    if v in vowels:\n",
    "        print(i,v)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf19ad7c",
   "metadata": {},
   "source": [
    "# 3.列表的一般方法\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83db2e70",
   "metadata": {},
   "source": [
    "## 本周作业： 课堂堂练习 + 如下表所示的表格 ，总结 列表的所有方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bc6e8de",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5af6e2f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e39d42cc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "3b01ee8f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'cygg', 'lcy', 'lcysz']"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"xiaohong\",\"cygg\",\"lcy\",\"lcysz\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "31762dbd",
   "metadata": {},
   "source": [
    "> 1.append() 列表的新增，增加元素至列表的末尾"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "7d4ff57b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "7ce55250",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"cygg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "51af1b97",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'cygg', 'lcy', 'lcysz', 'cygg']"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e6c9a12a",
   "metadata": {},
   "source": [
    "> 2.remove()选择列表的内容/值(values) ,删除\n",
    ">> * 注意 ：remove（）的一般步骤：1.先查询in 2.再删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "d108b8e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "num_list = [1,4,4,6,5,4,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "28093f3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "num_list.remove(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "cf312035",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 6, 5, 4, 2]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "num_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "32ddd665",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "02fe04ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "eaa0c2f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove()的一般步骤\n",
    "if \"Mary\" in names: # 先查询，再删除\n",
    "    names.remove(\"Mary\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "53affaaa",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"cygg\" in names:\n",
    "    names.remove(\"cygg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "eb8cb5be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'lcy', 'lcysz']"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "4275f0db",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"cygg\" in names:\n",
    "    names.remove(\"cygg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "a3911176",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'lcy', 'lcysz']"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "32eab489",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"cygg\" in names:\n",
    "    names.remove(\"cygg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "f13bd748",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'lcy', 'lcysz']"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8affe06",
   "metadata": {},
   "source": [
    "> 3.pop() pop(index=-1,/)默认删除 最后一位的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "e0b25522",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "4d1471bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'lcysz'"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop()#系统默认删除最后一个"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "afb4d22d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong', 'lcy']"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "dde25555",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'lcy'"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "6e2b0a46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaohong']"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "2b8aa195",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 删除实践：\n",
    "\n",
    "stu_id = [\n",
    "     \"210001001\",\n",
    "     \"210001002\",\n",
    "     \"20001003\",\n",
    "     \"2100010004\",\n",
    "     \"210001005\",\n",
    "     \"210001006\",\n",
    "     \"210001007\"\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "3df870d8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210001001\n",
      "20001003\n",
      "210001005\n",
      "210001007\n"
     ]
    }
   ],
   "source": [
    "# remove\n",
    "odds = [1,3,5,7,9]\n",
    "for i in stu_id:\n",
    "#    print(i[-1])\n",
    "    if int(i[-1]) in odds:\n",
    "        print(i)\n",
    "        stu_id.remove(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "bed5130f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['210001002', '2100010004', '210001006']"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "72d93bb8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# pop\n",
    "stu_id = [\n",
    "     \"210001001\",\n",
    "     \"210001002\",\n",
    "     \"20001003\",\n",
    "     \"2100010004\",\n",
    "     \"210001005\",\n",
    "     \"210001006\",\n",
    "     \"210001007\"\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "05aab900",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 210001001\n",
      "1 20001003\n",
      "2 210001005\n",
      "3 210001007\n"
     ]
    }
   ],
   "source": [
    "for i,v in enumerate(stu_id):\n",
    "    print(i,v)\n",
    "    if int(v[-1]) in odds:\n",
    "        stu_id.pop(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "40ec3a80",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 删除实践：\n",
    "\n",
    "stu_id_分数= [78,88,77,78,90,90,78,88,90,89,95]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "ac93e2c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "78\n",
      "77\n",
      "90\n",
      "90\n",
      "78\n",
      "90\n",
      "89\n",
      "95\n"
     ]
    }
   ],
   "source": [
    "#remove时 可能需要重复运行 才可以按照指定要求删除所有的值\n",
    "#分数低于85的删除\n",
    "for i in stu_id_分数:\n",
    "    print(i)\n",
    "    if i < 85:\n",
    "        stu_id_分数.remove(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "da3d192f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[88, 90, 90, 78, 88, 90, 89, 95]"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id_分数#重复运行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "id": "7bba948a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 78\n",
      "78\n",
      "1 77\n",
      "77\n",
      "2 90\n",
      "3 90\n",
      "4 78\n",
      "78\n",
      "5 90\n",
      "6 89\n",
      "7 95\n"
     ]
    }
   ],
   "source": [
    "#pop()删除  错误示范!!!!!\n",
    "stu_id_分数= [78,88,77,78,90,90,78,88,90,89,95]\n",
    "for i,v in enumerate(stu_id_分数):\n",
    "    print(i,v)\n",
    "    if v < 85:\n",
    "        print(stu_id_分数.pop(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "f5531b70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 2, 3, 6]"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pop_list = [] #\n",
    "stu_id_分数= [78,88,77,78,90,90,78,88,90,89,95]\n",
    "for i,v in enumerate(stu_id_分数):\n",
    "    if v <85:\n",
    "        pop_list.append(i)\n",
    "pop_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60757a16",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
